<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑样式</title>
</head>
<body>

<script type="text/html" id="form">
    <input type="hidden" name="id" value="{{d.id}}"/>
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <blockquote class="layui-elem-quote">基础信息</blockquote>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>工具主体颜色</label>
                    <div style="margin-left: 30px;">
                        <div id="color"></div>
                        <input type="hidden" name="body_color" id="choose_color" value="{{d.body_color}}"  />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>标签底色</label>
                    <div style="margin-left: 30px;">
                        <div id="color1"></div>
                        <input type="hidden" name="label_color" id="choose_color1" value="{{d.label_color}}"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>角色名称底色</label>
                    <div style="margin-left: 30px;">
                        <div id="color2"></div>
                        <input type="hidden" name="role_bottom_color" id="choose_color2"  value="{{d.role_bottom_color}}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>图鉴字体颜色</label>
                    <div style="margin-left: 30px;">
                        <div id="color3"></div>
                        <input type="hidden" name="guide_text_color" id="choose_color3"  value="{{d.guide_text_color}}"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>标签字体颜色</label>
                    <div style="margin-left: 30px;">
                        <div id="color4"></div>
                        <input type="hidden" name="label_text_color" id="choose_color4"  value="{{d.label_text_color}}"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>卡片底色</label>
                    <div style="margin-left: 30px;">
                        <div id="color5"></div>
                        <input type="hidden" name="card_color" id="choose_color5"  value="{{d.card_color}}"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <text style="color:red;">支持jpg、png，大小不超过5M，图片尺寸建议 3:1比例</text>
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        主题banner</label>
                    <div class="layui-input-block">
                        <div class="laytpUpload"
                             data-name="banner"
                             data-dir="xm_game/lineup/style/banner"
                             data-accept="image"
                             data-type="ali-oss"
                             data-layVerify="required"
                             data-showChoiceBtn="false"
                             data-uploaded="{{d.banner}}"
                             data-uploadedId="{{d.banner}}"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        不透明度</label>
                    <div class="layui-input-block">
                        <input type="text" name="opacity" value="{{d.opacity}}"  lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        基础权重值</label>
                    <div class="layui-input-block">
                        <input type="number" name="start_power_number" step=1 value="{{d.start_power_number}}"  lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        递减权重值</label>
                    <div class="layui-input-block">
                        <input type="number" name="reduce_power_number" step=1 value="{{d.reduce_power_number}}"  lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <blockquote class="layui-elem-quote">卡片内容编辑</blockquote>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        作者名称与头像是否展示</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="show_author"
                             data-sourceType="data"
                             data-source="[{name:'展示',value:1},{name:'不展示',value:2}]"
                             data-radio="true"
                             data-layVerify="required"
                             data-placeholder="请选择"
                             data-selected="{{d.show_author}}"
                        ></div>
                    </div>
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        是否可以点赞</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="can_like"
                             data-sourceType="data"
                             data-source="[{name:'可以',value:1},{name:'不可以',value:2}]"
                             data-radio="true"
                             data-layVerify="required"
                             data-placeholder="请选择"
                             data-selected="{{d.can_like}}"
                        ></div>
                    </div>
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        是否可以收藏</label>
                    <div class="layui-input-inline">
                        <div class="xmSelect"
                             data-name="can_collect"
                             data-sourceType="data"
                             data-source="[{name:'可以',value:1},{name:'不可以',value:2}]"
                             data-radio="true"
                             data-layVerify="required"
                             data-placeholder="请选择"
                             data-selected="{{d.can_collect}}"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        上传页面标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="index_title" value="{{d.index_title}}"  lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>
                        角色展示数量</label>
                    <div class="layui-input-block">
                        <input type="number" name="show_role_number" value="{{d.show_role_number}}"  lay-verify="required" autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        第一组阵容名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="team_one_name" value="{{d.team_one_name}}"   autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        第二组阵容名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="team_two_name" value="{{d.team_two_name}}"   autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>阵容标签关联资料库</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="relation_ids_4"
                             data-sourceType="route"
                             data-source="/admin.basic.category/index"
                             data-params='{"search_param":{"basic_game_id":{"value":"{{d.basic_game_id}}","condition":"="},"status":{"value":1,"condition":"="},"use_type":{"value":1,"condition":"="}}}'
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="false"
                             data-layVerify="required"
                             data-direction="down"
                             data-selected="{{d.relation_ids_4}}"
                        ></div>
                    </div>
                </div>
                <blockquote class="layui-elem-quote">上传内容展示编辑</blockquote>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        <text title="必填项" style="color:red;">*</text>主角色关联资料库</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="relation_ids_1"
                             data-sourceType="route"
                             data-source="/admin.basic.category/tree"
                             data-params='{"search_param":{"basic_game_id":{"value":"{{d.basic_game_id}}","condition":"="},"status":{"value":1,"condition":"="},"use_type":{"value":2,"condition":"="}}}'
                             data-sourceTree="true"
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="false"
                             data-layVerify="required"
                             data-direction="down"
                             data-selected="{{d.relation_ids_1}}"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                      主角标签关联资料库</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="master_content_label_id"
                             data-sourceType="route"
                             data-source="/admin.basic.category/index"
                             data-params='{"search_param":{"basic_game_id":{"value":"{{d.basic_game_id}}","condition":"="},"status":{"value":1,"condition":"="},"use_type":{"value":1,"condition":"="}}}'
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="true"
                             data-direction="down"
                             data-selected="{{d.master_content_label_id}}"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">
                        角色搭配关联资料库</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="relation_ids_2"
                             data-sourceType="route"
                             data-source="/admin.basic.category/tree"
                             data-params='{"search_param":{"basic_game_id":{"value":"{{d.basic_game_id}}","condition":"="},"status":{"value":1,"condition":"="},"use_type":{"value":3,"condition":"="}}}'
                             data-textField="name"
                             data-valueField="id"
                             data-sourceTree="true"
                             data-paging="true"
                             data-direction="down"
                             data-selected="{{d.relation_ids_2}}"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        搭配图鉴展示数量</label>
                    <div class="layui-input-block">
                        <input type="number" name="content_number" value="{{d.content_number}}"  autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        搭配标签关联资料库</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="relation_ids_3"
                             data-sourceType="route"
                             data-source="/admin.basic.category/index"
                             data-params='{"search_param":{"basic_game_id":{"value":"{{d.basic_game_id}}","condition":"="},"status":{"value":1,"condition":"="},"use_type":{"value":1,"condition":"="}}}'
                             data-textField="name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="false"
                             data-direction="down"
                             data-selected="{{d.relation_ids_3}}"
                        ></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        标签展示数量</label>
                    <div class="layui-input-block">
                        <input type="number" name="label_number" value="{{d.label_number}}"   autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <blockquote class="layui-elem-quote">配置字段名称</blockquote>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        详情页标题名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="detail_title_name" value="{{d.detail_title_name}}"   autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发布页标题名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="publish_title_name" value="{{d.publish_title_name}}"  autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发布页介绍名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="publish_introduce_name" value="{{d.publish_introduce_name}}"  autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发布页选择角色名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="publish_select_role_name" value="{{d.publish_select_role_name}}"  autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发布页选择图鉴名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="publish_select_guide_name" value="{{d.publish_select_guide_name}}"  autocomplete="off" placeholder="请输入"
                               class="layui-input">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="laytp-form">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if (localStorage.getItem("staticDomain")) {
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    } else {
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v=" + localStorage.getItem("version") + "'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v=" + localStorage.getItem("version") + "'><\/script>");
    }
</script>
<script>
    layui.use(['laytp','colorpicker'], function () {
        let colorpicker = layui.colorpicker;
        let form = layui.form;
        //获取参数ID
        var id = facade.getUrlParam('id');
        if(!id){
            facade.error('参数ID不能为空');
            return false;
        }
        facade.ajax({
            route: "/admin.lineup.style/info",
            data: {id: id},
            successAlert: false,
            showLoading: true
        }).done(function(res){
            if(res.code === 0){
                layui.laytpl($("#form").html()).render(res.data,function(string){
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });
                //常规使用
                colorpicker.render({
                    elem: '#color' //绑定元素
                    ,color:res.data.body_color
                    ,change: function(color){ //颜色改变的回调
                        $('#choose_color').val(color);
                    }
                });
                colorpicker.render({
                    elem: '#color1' //绑定元素
                    ,color:res.data.label_color
                    ,change: function(color){ //颜色改变的回调
                        $('#choose_color1').val(color);
                    }
                });
                colorpicker.render({
                    elem: '#color2' //绑定元素
                    ,color:res.data.role_bottom_color
                    ,change: function(color){ //颜色改变的回调
                        $('#choose_color2').val(color);
                    }
                });
                colorpicker.render({
                    elem: '#color3' //绑定元素
                    ,color:res.data.guide_text_color
                    ,change: function(color){ //颜色改变的回调
                        $('#choose_color3').val(color);
                    }
                });
                colorpicker.render({
                    elem: '#color4' //绑定元素
                    ,color:res.data.label_text_color
                    ,change: function(color){ //颜色改变的回调
                        $('#choose_color4').val(color);
                    }
                });
                colorpicker.render({
                    elem: '#color5' //绑定元素
                    ,color:res.data.card_color
                    ,change: function(color){ //颜色改变的回调
                        $('#choose_color5').val(color);
                    }
                });
            }
        });
        form.on('submit(laytp-form)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.lineup.style/edit',
                data:data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>